package com.wish.wishhouse_resource.controller;


import com.wish.wishhouse_resource.entity.TbHouseInfo;
import com.wish.wishhouse_resource.entity.TbPrivateFacility;
import com.wish.wishhouse_resource.service.ITbHouseInfoService;
import com.wish.wishhouse_resource.service.ITbPrivateFacilityService;
import org.springframework.beans.factory.annotation.Autowired;
import com.wish.wishhouse_resource.entity.TbHouseInfo;
import com.wish.wishhouse_resource.service.ITbHouseInfoService;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import vo.ResultEntity;

import java.util.List;
import utils.DateUtils;
import vo.ResultEntity;

import javax.annotation.Resource;
import java.util.UUID;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author zhangshuxin
 * @since 2021-03-28
 */
@RestController
@RequestMapping("/tbHouseInfo")
public class TbHouseInfoController {
    @Resource
    private ITbHouseInfoService tbHouseInfoService;

    @RequestMapping("/saveHouseRoom")
    public ResultEntity saveHouseRoom(@RequestBody TbHouseInfo tbHouseInfo) {

        tbHouseInfo.setCreateTime(DateUtils.getNowTime());
        tbHouseInfo.setPublicFacility(String.join(",", tbHouseInfo.getPublicFacilityListy()));
        boolean save = tbHouseInfoService.save(tbHouseInfo);
        return ResultEntity.ok(save);
    }

    /*@Autowired
    private ITbHouseInfoService tbHouseInfoService;*/
    @Autowired
    private ITbPrivateFacilityService tbPrivateFacilityService;


    @RequestMapping("save")
    public ResultEntity save(@RequestBody TbHouseInfo tbHouseInfo){

        return tbHouseInfoService.saveHouseInfo(tbHouseInfo);
    }

    @RequestMapping("selectAllPrivate")
    public ResultEntity selectAllPrivate(){
        List<TbPrivateFacility> list = tbPrivateFacilityService.list();
        return ResultEntity.ok("200",list);
    }

/*    @RequestMapping("addHouseInfoPic")
    public ResultEntity addHouseInfoPic(@RequestBody MultipartFile file){
        String upload = uploadTemplate.upload(file);
        System.err.println(upload);
        return ResultEntity.ok("200",upload);
    }*/
}

